﻿<div>
    <div style="margin-bottom:20px; margin-left:10px;" class = "pagination">
            Found Orders: 
        <span style="color:blue">@ViewBag.OrdersCount</span>

        <span style="margin-left:440px;" class = "pagination">
@if(ViewBag.itemOnPage == 10 )
{
                @Ajax.ActionLink("25 item on page", "OrderTable", new { orderOrderOsBy = ViewBag.SortById ,itemOnPage = 25,page = ViewBag.currentPage ,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition}, new AjaxOptions
{
    UpdateTargetId = "table",
    LoadingElementId = "loading",
    LoadingElementDuration = 1000
})
}
            else{
                    @Ajax.ActionLink("10 item on page", "OrderTable", new { orderOrdersBy = ViewBag.SortById ,itemOnPage = 10,page = ViewBag.currentPage ,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition }, new AjaxOptions
{
    UpdateTargetId = "table",
    LoadingElementId = "loading",
    LoadingElementDuration = 1000
})
    
}
        </span>
    </div>

    <div>

    <table class="rounded-corner">
        <thead>
        <tr>
            <th  class="rounded-company"></th>
            <th>@Ajax.ActionLink("OrderId","OrderTable",new { orderOrdersBy = ViewBag.SortById ,itemOnPage = ViewBag.itemOnPage,page = ViewBag.currentPage ,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition},new AjaxOptions{ UpdateTargetId="table"})</th>
            <th>@Ajax.ActionLink("ClientName", "OrderTable", new { orderOrdersBy = ViewBag.SortByCustomer,itemOnPage = ViewBag.itemOnPage, page = ViewBag.currentPage, searchString = ViewBag.searchString, listSelectField = ViewBag.listSelectField, listSelectCondition = ViewBag.listSelectCondition }, new AjaxOptions { UpdateTargetId = "table" })</th>
            <th>@Ajax.ActionLink("Assignee","OrderTable",new { orderOrdersBy = ViewBag.SortByMerchandiser,itemOnPage = ViewBag.itemOnPage, page = ViewBag.currentPage,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition },new AjaxOptions{ UpdateTargetId="table"})</th>
            <th>@Ajax.ActionLink("DeliveryDate", "OrderTable", new { orderOrdersBy = ViewBag.SortByDate,itemOnPage = ViewBag.itemOnPage, page = ViewBag.currentPage,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition },new AjaxOptions{ UpdateTargetId="table"})</th>
            <th>@Ajax.ActionLink("Accepted","OrderTable",new { orderOrdersBy =  ViewBag.SortByAccepted,itemOnPage = ViewBag.itemOnPage, page = ViewBag.currentPage,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition },new AjaxOptions{ UpdateTargetId="table"})</th>
            <th>@Ajax.ActionLink("Delivered","OrderTable",new { orderOrdersBy = ViewBag.SortByDelivered ,itemOnPage = ViewBag.itemOnPage, page = ViewBag.currentPage,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition },new AjaxOptions{ UpdateTargetId="table"})</th>
            <th class="rounded-q4">Operate</th>
        </tr>
        </thead>
        <tbody>
    @foreach (var c in ViewBag.Orders)
    {
        <tr>
            <td></td>
            <td>@c.OrderId</td>
            <td>@c.user.LoginName</td>
            <td>@c.Assigned</td>
            <td>@c.DeliveryDate</td>
            <td>@if (c.Accepted)
                {
                    <img src="../../Content/images/valid.png" alt="Edit" title="Edit" border="0" />
                }
                else
                {
                    <img src="../../Content/images/user_logout.png" alt="Edit" title="Edit" border="0" />
                }

            </td>
            <td>
                @if (c.Delivered)
                {
                    <img src="../../Content/images/valid.png" alt="Edit" title="Edit" border="0" />
                }
                else
                {
                    <img src="../../Content/images/user_logout.png" alt="Edit" title="Edit" border="0" />
                }

            </td>
          
            
            <td>
                @if (User.Identity.Name.Equals(c.Assigned))
                {
                <a href="@Url.Action("Edit", "Merchandise", new { @orderId = c.OrderId , @userLogin = c.Assigned  })"><img src="../../Content/images/user_edit.png" alt="Edit" title="Edit" border="0" /></a>
                }
                </td>
        </tr>
               
    }
    @if (ViewBag.Orders.Count != ViewBag.itemOnPage)
    {
        for (int i = 0; i <= ViewBag.itemOnPage - ViewBag.Orders.Count; i++)
        {
            <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
        }
    }
    </tbody>
    </table>
      </div>
     <span id="numberOfPage">Page #: @ViewBag.currentPage from @ViewBag.lastPage</span>
        <div class="pagination">
           

         @if (ViewBag.currentPage == 1)
         {
             <span class="disabled">first</span>
             <span class="disabled">< prev</span>
         }
         else
         
         {
             <span>

                 @Ajax.ActionLink("first", "OrderTable", new { 
                
                  itemOnPage = ViewBag.itemOnPage,
                  searchString = ViewBag.searchString, 
                  listSelectField = ViewBag.listSelectField, 
                  listSelectCondition = ViewBag.listSelectCondition, 
                  orderOrdersBy = ViewBag.currentSortOrdersBy, 
                  page = 1 
        
             },new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                        LoadingElementDuration=1000})

             </span>
             
             <span>
                 @Ajax.ActionLink("< prev", "OrderTable", new { 
                itemOnPage = ViewBag.itemOnPage,
                  searchString = ViewBag.searchString, 
                  listSelectField = ViewBag.listSelectField, 
                  listSelectCondition = ViewBag.listSelectCondition, 
                  orderOrdersBy = ViewBag.currentSortOrdersBy, 
                  page = ViewBag.currentPage - 1 
                  
              }, new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                          LoadingElementDuration=1000})

             </span>
             
             
         }
         @if (ViewBag.OrdersCount <= ViewBag.currentPage * ViewBag.itemOnPage)
         {
             <span class="disabled">next ></span>
             <span class="disabled">last</span>
         }
            else
            {
                 <span>

                     @Ajax.ActionLink("next >", "OrderTable", new {
                        itemOnPage = ViewBag.itemOnPage,
                      searchString =ViewBag.searchString, 
                      listSelectField =ViewBag.listSelectField, 
                      listSelectCondition = ViewBag.listSelectCondition, 
                      orderOrdersBy = ViewBag.currentSortOrdersBy, 
                      page = ViewBag.currentPage + 1 
              
                  }, new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                              LoadingElementDuration=1000})

                 </span>
                 <span>
                     @Ajax.ActionLink("last", "OrderTable", new {
                        itemOnPage = ViewBag.itemOnPage,
                      searchString =ViewBag.searchString, 
                      listSelectField =ViewBag.listSelectField, 
                      listSelectCondition = ViewBag.listSelectCondition, 
                      orderOrdersBy = ViewBag.currentSortOrdersBy, 
                      page = ViewBag.lastPage
              
                  }, new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                              LoadingElementDuration=1000})

                 </span>
         }
   </div>
    
</div>